package com.eigaland.change_machine.business.login

import android.view.View
import androidx.lifecycle.MutableLiveData
import com.eigaland.change_machine.displaymodel.HomeDisplayModel
import com.eigland.eigaland_lib.base.BaseVM
import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import movie6.posprintercept2.extensions.customLaunch

public class LoginFragmentVM :BaseVM(){

    var deviceId = MutableLiveData<String>()

    private var loginRepository = LoginFragmentRepository()

    var clickableStatus = MutableLiveData<Boolean>()

    var loginStatus = MutableLiveData<HomeDisplayModel>()

    var loadingProgressStatus = MutableLiveData<Boolean>()

    var loginSec = ""

    override fun initData() {

    }

    override fun destroy() {

    }

    override fun saveData() {

    }

    override fun onResume() {

    }



    /**
     *
     */
    fun loginWithId(view:View){
        loadingProgressStatus.postValue(true)
      customLaunch({


          var registerResult = loginRepository.registerDevice(deviceId.value)

          loginStatus.postValue(registerResult)

          loadingProgressStatus.postValue(false)

      },{
           com.orhanobut.logger.Logger.e(it.printStackTrace().toString())
            var homeDisplayModel = HomeDisplayModel()
            homeDisplayModel.errorMsg = it.message!!
           loadingProgressStatus.postValue(false)

        },{

        })





    }
}